import {observable, action, toJS} from 'mobx';
import { Tools } from 'weaver-mobile'
import { Browser, BrowserHrm, Upload  } from 'weaver-mobile-page'

const getLabel = Tools.getLabel

export default class NewTaskStore {

  @observable 
  taskNewHrmPrincipalBrowserStore = new BrowserHrm.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewHrmPartnerBrowserStore = new BrowserHrm.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewSupTaskBrowserStore = new Browser.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewRelateTaskBrowserStore = new Browser.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewRelateGoalBrowserStore = new Browser.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewRelateDocBrowserStore = new Browser.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewRelateProcessBrowserStore = new Browser.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewRelateCustomerBrowserStore = new Browser.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewRelateProjectBrowserStore = new Browser.Store({ route: '/taskHome/newTask' })

  @observable 
  taskNewRelateAttachmentBrowserStore = new Upload.Store({ route: '/taskHome/newTask' })

  @observable
  todovalOptions = [
    {
      key: "1",
      showname: getLabel(15537,'今日')
    },
    {
      key: "2",
      showname: getLabel(22488,'明天')
    },
    {
      key: "3",
      showname: getLabel(382509,'即将')
    },
    {
      key: "4",
      showname: getLabel(382499,'不标记')
    },
    {
      key: "5",
      showname: getLabel(382498,'备忘')
    }
  ]

  @observable
  urgentLevelOptions = [
      {
          key: "0",
          showname: getLabel(15808, '未设置')
      },{
          key: "1",
          showname: getLabel(382501, '重要紧急')
      },{
          key: "2",
          showname: getLabel(382502, '重要不紧急')
      },{
          key: "3",
          showname: getLabel(382503, '不重要紧急') 
      },{
          key: "4",
          showname: getLabel(382504, '不重要不紧急')
      }
  ]

  @observable
  sorttype = ""

  @action
  changeSorttype = (sorttype) => {
    this.sorttype = sorttype
  }

  @observable
  datetype = ""

  @action
  changeDatetype = (datetype) => {
    this.datetype = datetype
  }

  @observable
  baseInfoOpen = false

  @action
  changeBaseInfoOpen = (baseInfoOpen) => {
    this.baseInfoOpen = baseInfoOpen
  }

  @observable
  taskname = ""

  @action
  changeTaskname = (taskname) => {
    this.taskname = taskname
  }

  @observable
  todoval = ""

  @action
  changeTodoval = (todoval) => {
    this.todoval = todoval
  }

  @observable
  principal = []

  @action
  changePrincipal = (principal) => {
      this.principal = principal
  }

  @observable
  partner = []

  @action
  changePartner = (partner) => {
      this.partner = partner
  }

  @observable
  supTask = []

  @action
  changeSupTask = (supTask) => {
      this.supTask = supTask
  }

  @observable
  urgentLevel = ""

  @action
  changeUrgentLevel = (level) => {
      this.urgentLevel = level
  }

  @observable
  enddate = ""

  @action
  changeEnddate = (enddate) => {
    this.enddate = enddate
  }

  @observable
  remark = ""

  @action
  changeRemark = (remark) => {
    this.remark = remark
  }

  @observable
  relateTask = []

  @action
  changeRelateTask = (relateTask) => {
      this.relateTask = relateTask
  }

  @observable
  relateGoal = []

  @action
  changeRelateGoal = (relateGoal) => {
      this.relateGoal = relateGoal
  }

  @observable
  relateDoc = []

  @action
  changeRelateDoc = (relateDoc) => {
      this.relateDoc = relateDoc
  }

  @observable
  relateProcess = []

  @action
  changeRelateProcess = (relateProcess) => {
      this.relateProcess = relateProcess
  }

  @observable
  relateCustomer = []

  @action
  changeRelateCustomer = (relateCustomer) => {
      this.relateCustomer = relateCustomer
  }

  @observable
  relateProject = []

  @action
  changeRelateProject = (relateProject) => {
      this.relateProject = relateProject
  }

  @observable
  relateAttachment = []

  @action
  changeRelateAttachment = (relateAttachment) => {
      this.relateAttachment = relateAttachment
  }

  @observable
  category = ""

  @action
  changeCategory = (category) => {
    this.category = category
  }

  @observable
  maxUploadSize = ""

  @action
  changeMaxUploadSize = (maxUploadSize) => {
    this.maxUploadSize = maxUploadSize
  }

  // @observable
  // defaultPrincipalid = ""

  // @action
  // changeDefaultPrincipalid = (principalid) => {
  //   this.defaultPrincipalid = principalid
  // }

  // @observable
  // defaultPrincipalname = ""

  // @action
  // changeDefaultPrincipalname = (principalname) => {
  //   this.defaultPrincipalname = principalname
  // }

  @observable
  isSaving = false

  @action
  changeIsSaving = (isSaving) => {
    this.isSaving = isSaving
  }

  @action
  clearValues = () => {
    this.taskname = "",
    this.todoval = "",
    this.principal = [],
    this.partner = [],
    this.supTask = [],
    this.urgentLevel = "",
    this.enddate = "",
    this.remark = "",
    this.relateTask = [],
    this.relateGoal = [],
    this.relateDoc = [],
    this.relateProcess = [],
    this.relateCustomer = [],
    this.relateProject = [],
    this.relateAttachment = []
  }
}